// 秒数转MM:ss格式
export function secondToMMss(seconds: number) {
  if (isNaN(seconds) || seconds < 0) return '00:00' // 处理 NaN 和负数情况

  const minutes = Math.floor(seconds / 60) // 直接计算总分钟数
  const secs = Math.floor(seconds % 60)

  return `${String(minutes).padStart(2, '0')}:${String(secs).padStart(2, '0')}`
}

// 从当前URL获取查询参数 转对象
export function getQueryParams(query: string): Record<string, string> {
  const params = new URLSearchParams(query)
  const result: Record<string, string> = {}

  params.forEach((value, key) => {
    result[key] = value
  })

  return result
}
